<div id="main_container" style="margin-left: 20%; ">
<script type="text/javascript" language="JavaScript1.5">
    function validate()
    {
        var form = document.getElementById('searchForm');
        var keyword = document.getElementById("keyword");
        form.action += form.search_type.value + "/";
        form.action += keyword.value;
        form.submit();
    }
</script>

<fieldset style="width:400px;">
    <legend>Thông tin sinh viên</legend>
    Tên sinh viên : <strong><?php echo $user->name; ?></strong><br />
    MSSV : <strong><?php echo $user->id;?></strong>
</fieldset>
<br/><br/>
<?php if(isset($search)) $onSearch = TRUE; else $onSearch = FALSE; ?>
<fieldset style="width:400px;">
    <legend>Tìm kiếm</legend>
    <form id="searchForm"   action="<?php echo Utility::getSiteUrl();?>/result/search/" method="post" >
    Từ khóa : <input type="text" name="keyword" id="keyword" size="50" value="<?php if($onSearch) echo $search['keyword'];?>"/><br/>
    Tìm theo : <select name="search_type">
                    <option value="1" <?php if($onSearch && $search['type'] == 1) echo "selected='selected'"; ?> >Tên môn</option>
                    <option value="2"
        <?php if($onSearch && $search['type'] == 2) echo "selected='selected'"; ?> >Mã lớp</option>
                </select><br />
    <input type="submit" value="Thực hiện" onclick="validate();" class="art-button-wrapper"/>
    </form>
</fieldset>
    <br />
    <table border="1" cellpadding="5" style="width:420px">
        <thead>
            <tr>
                <th>Mã lớp</th>
                <th>Tên môn học</th>
                <th>Điểm</th>
            </tr>
        </thead>
        <tbody>
            <?php
            $size = $result->getSize();
            if($size > 0)
            {
                for($i = 0; $i < $size;$i++)
                {
                    $row = $result->getRow($i);
                ?>
                    <tr>
                        <td><?php echo $row->class_id; ?></td>
                        <td><?php echo $row->sub_name; ?></td>
                        <td><?php echo $row->mark; ?></td>
                    </tr>
                <?php
                }
            }
            else
            {
                ?>
                <tr>
                    <td colspan="3"><?php if($onSearch) echo "Không tìm thấy kết quả"; else echo "Hiện chưa có kết quả nào";?></td>
                </tr>
                <?php
            }
            ?>
            <tr>
                <td colspan="3" style="text-align: right;">
                    <strong><a href="<?php echo Utility::getSiteUrl() . '/result/export/' . ((isset($current_action) && $current_action == 'search') ? 'search/' . $queryString : '')?>">Xuất ra tệp .doc </a></strong><br /> 
                </td>
            </tr>
        </tbody>
    </table>
    <br /><br />
    </div>